Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

659
Visualizações
Warning: SafeValue must use [property]=binding

I'm trying to send an element getBoundingClientRect() to my component this way:

<object [fromTop]="element.getBoundingClientRect().top"></object>

In my component html I do this since I got a note that it was "unsafe"

this.fromTop = this.sanitizer.bypassSecurityTrustStyle(this.fromTop);

<div
style="position:absolute;top:{{fromTop}}px;">Top:{{fromTop}}</div>

But after adding the sanitizer I get the following message:

SafeValue must use [property]=binding:

What's wrong? How I can let my object be in an absolute position that equals to top: {{fromTop}}px?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

{{}} is for string binding only. A sanitized value is not a plain string anymore and if you use {{}} the sanitization marker is removed.

You need to sanitize the whole style value and then bind it to [style]="..."

but a more angulary way would be using Angular bindings or directives

<div [style.top.px]="fromTop" [style.position]="'absolute'">Top:{{fromTop}}</div>

<div [ngStyle]="{top: fromTop + 'px', position: 'absolute'}">Top:{{fromTop}}</div>

This way no sanitization is required.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda